/**
 * 
 */
package com.p2p.front.service;

import java.util.Date;
import java.util.List;

import com.github.pagehelper.PageInfo;
import com.p2p.base.model.Money;
import com.p2p.base.page.PageVo;
import com.p2p.front.dal.model.LoanInfo;
import com.p2p.front.dal.model.LoanRepay;
import com.p2p.front.dal.model.LoanVariation;
import com.p2p.front.result.LoanRepayResult;
import com.p2p.front.web.form.TenderRepayForm;

/**
 * @author ruiqi
 *
 */
public interface LoanRepayService {

	void createRepay(LoanRepay repay);
	
	void create(LoanInfo loanInfo,LoanVariation loanStatus);
	
	List<LoanRepay> queryByLoanId(Long loanId);
	
	List<LoanRepay> queryByLoanIdAndStatus(Long loanId,Integer status);
	
	LoanRepay getByRid(Long rid);
	
	public LoanRepay selectForUpdateByRid(Long rid);

	boolean updateForAddRepay(Long loanId,Integer no,Money returnAmount,Money returnPrincipal);
	
	boolean updateStatus(Long rid,Integer oldStatus,Integer status);
	
	boolean updateStatus(Long loanId, Integer no, Integer oldStatus, Integer status);
	
	boolean updateStatusForReturn(Long rid, Integer oldStatus, Integer status);
	
	PageInfo listPage(TenderRepayForm form);
	
	//public LoanRepayResult doRepay(LoanRepay loanRepay, boolean advance,LoanInfo loanInfo);
	
	public LoanRepayResult doRepay2(Long loanRepayId, boolean advance,LoanInfo loanInfo);
	
	public LoanRepayResult doTransRepayForAdvance(Long loanId, Money Fine,boolean needRepay);
	
	public boolean doTransForLoanRepay(LoanRepay loanRepay,LoanInfo loanInfo);

	PageVo queryByTime(PageVo form);

	PageVo queryExceedRepayByTime(PageVo form);
	
	List<LoanRepay> queryByStatusAndReturnTime(Integer status,Date startTime,Date endTime);

	/**
	 * 查询n天内即将到期的还款
	 * @param days
	 * @return
	 */
	public List<LoanRepay> queryWillExpireByDays(int days);
	
	/**
	 * 查询逾期超过n天的还款
	 * @param days
	 * @return
	 */
	public List<LoanRepay> queryHasExpireOverDays(int days);
	
	/**
	 * 查询逾期不到n天的还款
	 * 
	 * @param days
	 * @return
	 */
	public List<LoanRepay> queryHasExpireLessDays(int days);
	
	/**
	 * 
	 * 过期还款
	 * @param pageVo
	 * @return
	 */
	public List<LoanRepay> queryHasExpireAndRepayed();
	/**
	 * 分页
	 * 查询n天内即将到期的还款
	 * @param days
	 * @param pageVo
	 * @return
	 */
	public PageVo queryWillExpireByDaysPage(int days,PageVo pageVo);
	
	/**
	 * 分页
	 * 
	 * 查询逾期不到n天的还款
	 * @param days
	 * @param pageVo
	 * @return
	 */
	public PageVo queryHasExpireLessDaysPage(int days,PageVo pageVo);
	
	/**
	 * 分页
	 * 
	 * 查询逾期超过n天的还款
	 * @param days
	 * @param pageVo
	 * @return
	 */
	public PageVo queryHasExpireOverDaysPage(int days,PageVo pageVo);
	
	/**
	 * 分页
	 * 
	 * 过期还款
	 * @param pageVo
	 * @return
	 */
	public PageVo queryHasExpireAndRepayedPage(PageVo pageVo);
}
